#pragma once

#include "HashTable.h"

namespace hash_bucket
{
	template <class K,class V>
	class unordered_map
	{
	public:
		struct MapKeyOfT
		{
			const K& operator()(const pair<K,V>& kv)
			{
				return kv.first;
			}
		};

		typedef typename HashBucket<K, pair<const K, V>, MapKeyOfT>::iterator iterator;
		typedef typename HashBucket<K, pair<const K, V>, MapKeyOfT>::const_iterator const_iterator;


		pair<iterator,bool> insert(const pair<K, V>& kv)
		{
			return _hb.Insert(kv);
		}

		V& operator[](const K& key)
		{
			pair<iterator, bool> ret = _hb.Insert(make_pair(key, V()));
			return ret.first->second;
		}

		iterator begin()
		{
			return _hb.begin();
		}

		iterator end()
		{
			return _hb.end();
		}

		const_iterator begin()const
		{
			return _hb.begin();
		}

		const_iterator end()const
		{
			return _hb.end();
		}


	private:
		HashBucket<K, pair<const K,V>, MapKeyOfT> _hb;
	};
}


